<?php
namespace app\common\controller;
use think\Controller;
use base\pay\WxApi;
use base\BaseMethod;

class System extends Controller
{
	
	/**
    * 获取支付公钥
    * /admin/soft/System/getPubKey
	* @is_need_login true
    */
	public function getPubKey(){
		try {
			$res =(new WxApi)->getPubKey();
            $fie = str_replace("\\","/",base_path()).'/cacert/'.'pubkey.pem';
            $fie_new = str_replace("\\","/",base_path()).'/cacert/'.'pubkey_new.pem';
            exec("openssl rsa -RSAPublicKey_in -in $fie -out $fie_new",$out,$return_val);
			return BaseMethod::ReSucess(
			  "成功！",
			  "注意执行 openssl rsa -RSAPublicKey_in -in $fie -out $fie_new"
            );
        } catch (\Exception $e) {
        	throw new \think\Exception( $e->getMessage() );
        }
	}
    
}
